{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {
    "collapsed": true,
    "pycharm": {
     "is_executing": false
    }
   },
   "outputs": [],
   "source": [
    "import dask.dataframe as dd\n",
    "import numpy as np\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "outputs": [],
   "source": [
    "\n",
    "from collections import defaultdict\n",
    "import numpy as np\n",
    "import pandas as pd\n",
    "\n",
    "import matplotlib.pyplot as plt\n",
    "import seaborn as sns\n",
    "%matplotlib inline"
   ],
   "metadata": {
    "collapsed": false,
    "pycharm": {
     "name": "#%%\n",
     "is_executing": false
    }
   }
  },
  {
   "cell_type": "code",
   "execution_count": 102,
   "outputs": [],
   "source": [
    "dfinput = pd.read_csv('train_sub_count.csv',chunksize=500000)"
   ],
   "metadata": {
    "collapsed": false,
    "pycharm": {
     "name": "#%%\n",
     "is_executing": false
    }
   }
  },
  {
   "cell_type": "code",
   "execution_count": 15,
   "outputs": [],
   "source": [
    "dtinput = pd.read_csv('test_sub_count.csv',chunksize=500000)"
   ],
   "metadata": {
    "collapsed": false,
    "pycharm": {
     "name": "#%%\n",
     "is_executing": false
    }
   }
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "outputs": [],
   "source": [
    "#dtinput = pd.read_csv('test_sub_count.csv',nrows=50,chunksize=500000)"
   ],
   "metadata": {
    "collapsed": false,
    "pycharm": {
     "name": "#%%\n",
     "is_executing": false
    }
   }
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "outputs": [
    {
     "data": {
      "text/plain": "Empty DataFrame\nColumns: [id, hour, C1, banner_pos, site_id, site_domain, site_category, app_id, app_domain, app_category, device_id, device_ip, device_model, device_type, device_conn_type, C14, C15, C16, C17, C18, C19, C20, C21, user_id, user_id&media_id, user_id&C14_d, user_id&C17_d, user_id&C14_h, user_id&C17_h, time]\nIndex: []\n\n[0 rows x 30 columns]",
      "text/html": "<div>\n<style scoped>\n    .dataframe tbody tr th:only-of-type {\n        vertical-align: middle;\n    }\n\n    .dataframe tbody tr th {\n        vertical-align: top;\n    }\n\n    .dataframe thead th {\n        text-align: right;\n    }\n</style>\n<table border=\"1\" class=\"dataframe\">\n  <thead>\n    <tr style=\"text-align: right;\">\n      <th></th>\n      <th>id</th>\n      <th>hour</th>\n      <th>C1</th>\n      <th>banner_pos</th>\n      <th>site_id</th>\n      <th>site_domain</th>\n      <th>site_category</th>\n      <th>app_id</th>\n      <th>app_domain</th>\n      <th>app_category</th>\n      <th>...</th>\n      <th>C19</th>\n      <th>C20</th>\n      <th>C21</th>\n      <th>user_id</th>\n      <th>user_id&amp;media_id</th>\n      <th>user_id&amp;C14_d</th>\n      <th>user_id&amp;C17_d</th>\n      <th>user_id&amp;C14_h</th>\n      <th>user_id&amp;C17_h</th>\n      <th>time</th>\n    </tr>\n  </thead>\n  <tbody>\n  </tbody>\n</table>\n<p>0 rows × 30 columns</p>\n</div>"
     },
     "metadata": {},
     "output_type": "execute_result",
     "execution_count": 7
    }
   ],
   "source": [
    "test_df = pd.read_csv('test_sub_count.csv',nrows=0)\n",
    "test_df.head()"
   ],
   "metadata": {
    "collapsed": false,
    "pycharm": {
     "name": "#%%\n",
     "is_executing": false
    }
   }
  },
  {
   "cell_type": "code",
   "execution_count": 14,
   "outputs": [],
   "source": [
    "test_df.to_csv('test_pre_over.csv',index=False)"
   ],
   "metadata": {
    "collapsed": false,
    "pycharm": {
     "name": "#%%\n",
     "is_executing": false
    }
   }
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "outputs": [],
   "source": [
    "columns = train_df.columns"
   ],
   "metadata": {
    "collapsed": false,
    "pycharm": {
     "name": "#%%\n"
    }
   }
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "outputs": [],
   "source": [
    "columns = test_df.columns\n"
   ],
   "metadata": {
    "collapsed": false,
    "pycharm": {
     "name": "#%%\n",
     "is_executing": false
    }
   }
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "outputs": [
    {
     "data": {
      "text/plain": "Index(['id', 'hour', 'C1', 'banner_pos', 'site_id', 'site_domain',\n       'site_category', 'app_id', 'app_domain', 'app_category', 'device_id',\n       'device_ip', 'device_model', 'device_type', 'device_conn_type', 'C14',\n       'C15', 'C16', 'C17', 'C18', 'C19', 'C20', 'C21', 'user_id',\n       'user_id&media_id', 'user_id&C14_d', 'user_id&C17_d', 'user_id&C14_h',\n       'user_id&C17_h', 'time'],\n      dtype='object')"
     },
     "metadata": {},
     "output_type": "execute_result",
     "execution_count": 9
    }
   ],
   "source": [
    "columns"
   ],
   "metadata": {
    "collapsed": false,
    "pycharm": {
     "name": "#%%\n",
     "is_executing": false
    }
   }
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "outputs": [
    {
     "data": {
      "text/plain": "Index(['user_id', 'user_id&media_id', 'user_id&C14_d', 'user_id&C17_d',\n       'user_id&C14_h', 'user_id&C17_h', 'time'],\n      dtype='object')"
     },
     "metadata": {},
     "output_type": "execute_result",
     "execution_count": 10
    }
   ],
   "source": [
    "columns[-7:]"
   ],
   "metadata": {
    "collapsed": false,
    "pycharm": {
     "name": "#%%\n",
     "is_executing": false
    }
   }
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "outputs": [],
   "source": [
    "import pickle"
   ],
   "metadata": {
    "collapsed": false,
    "pycharm": {
     "name": "#%%\n",
     "is_executing": false
    }
   }
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "outputs": [],
   "source": [
    "fwfs = open(\"fcount.pkl\",'rb')\n",
    "fset = pickle.load(fwfs)\n",
    "\n",
    "fwrd = open(\"rare_d.pkl\",'rb')\n",
    "rare_d = pickle.load(fwrd)\n",
    "\n",
    "fwidd = open(\"id_day.pkl\",'rb')\n",
    "id_day = pickle.load(fwidd)"
   ],
   "metadata": {
    "collapsed": false,
    "pycharm": {
     "name": "#%%\n",
     "is_executing": false
    }
   }
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "outputs": [
    {
     "traceback": [
      "\u001b[1;31m---------------------------------------------------------------------------\u001b[0m",
      "\u001b[1;31mNameError\u001b[0m                                 Traceback (most recent call last)",
      "\u001b[1;32m<ipython-input-9-3f4343571c9a>\u001b[0m in \u001b[0;36m<module>\u001b[1;34m\u001b[0m\n\u001b[0;32m      1\u001b[0m \u001b[0mfwfs\u001b[0m \u001b[1;33m=\u001b[0m \u001b[0mopen\u001b[0m\u001b[1;33m(\u001b[0m\u001b[1;34m\"fcount_test.pkl\"\u001b[0m\u001b[1;33m,\u001b[0m\u001b[1;34m'rb'\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[1;32m----> 2\u001b[1;33m \u001b[0mfset\u001b[0m \u001b[1;33m=\u001b[0m \u001b[0mpickle\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mload\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mfwfs\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m\u001b[0;32m      3\u001b[0m \u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m      4\u001b[0m \u001b[0mfwrd\u001b[0m \u001b[1;33m=\u001b[0m \u001b[0mopen\u001b[0m\u001b[1;33m(\u001b[0m\u001b[1;34m\"rare_d_test.pkl\"\u001b[0m\u001b[1;33m,\u001b[0m\u001b[1;34m'rb'\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m      5\u001b[0m \u001b[0mrare_d\u001b[0m \u001b[1;33m=\u001b[0m \u001b[0mpickle\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mload\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mfwrd\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n",
      "\u001b[1;31mNameError\u001b[0m: name 'pickle' is not defined"
     ],
     "ename": "NameError",
     "evalue": "name 'pickle' is not defined",
     "output_type": "error"
    }
   ],
   "source": [
    "fwfs = open(\"fcount_test.pkl\",'rb')\n",
    "fset = pickle.load(fwfs)\n",
    "\n",
    "fwrd = open(\"rare_d_test.pkl\",'rb')\n",
    "rare_d = pickle.load(fwrd)\n",
    "\n",
    "fwidd = open(\"id_day_test.pkl\",'rb')\n",
    "id_day = pickle.load(fwidd)"
   ],
   "metadata": {
    "collapsed": false,
    "pycharm": {
     "name": "#%%\n",
     "is_executing": false
    }
   }
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "outputs": [],
   "source": [
    "id_day"
   ],
   "metadata": {
    "collapsed": false,
    "pycharm": {
     "name": "#%%\n"
    }
   }
  },
  {
   "cell_type": "code",
   "execution_count": 16,
   "outputs": [],
   "source": [
    "count = 0\n",
    "uuid = \"??\"\n",
    "pdip = \"??\"\n",
    "\n"
   ],
   "metadata": {
    "collapsed": false,
    "pycharm": {
     "name": "#%%\n",
     "is_executing": false
    }
   }
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "outputs": [
    {
     "name": "stdout",
     "text": [
      "device_id\n"
     ],
     "output_type": "stream"
    }
   ],
   "source": [
    "for p_str in list(columns[3:]):\n",
    "    if p_str == 'device_id':\n",
    "        print(p_str)"
   ],
   "metadata": {
    "collapsed": false,
    "pycharm": {
     "name": "#%%\n",
     "is_executing": false
    }
   }
  },
  {
   "cell_type": "code",
   "execution_count": 107,
   "outputs": [],
   "source": [
    "def prep(df):\n",
    "    global count,uuid,pdip\n",
    "    count+=1\n",
    "    if count%200000 ==0:\n",
    "        print(count)\n",
    "    for p_str in list(columns[3:]):\n",
    "        if p_str == 'device_id':\n",
    "            did = \"did_\"+df['device_id']\n",
    "            rare = rare_d.get(did)\n",
    "            if rare !=None:\n",
    "                df['device_id'] = \"did_rare_\"+ str(rare)\n",
    "                continue\n",
    "        if p_str == 'device_ip':\n",
    "            dip = \"dip_\"+df['device_ip']\n",
    "            pdip = df['device_ip']\n",
    "            rare = rare_d.get(dip)\n",
    "            if rare !=None:\n",
    "                df['device_ip'] = \"dip_rare_\"+ str(rare)\n",
    "                continue\n",
    "        if p_str == 'user_id':\n",
    "            uid = \"uid_\"+df['user_id']\n",
    "            uuid = df['user_id']\n",
    "            rare = rare_d.get(uid)\n",
    "            if rare !=None:\n",
    "                df['user_id'] = \"uid_rare_\"+ str(rare)\n",
    "                continue\n",
    "            elif id_day.get(uid) == 1:\n",
    "                df['user_id'] = \"v_id_s\"\n",
    "                continue\n",
    "        if p_str+\"_\"+str(df[p_str]) not in fset and p_str not in list(columns[-7:]):\n",
    "            df[p_str] = p_str+\"_rare\"\n",
    "        else:\n",
    "            df[p_str] = p_str +\"_\" + str(df[p_str])\n",
    "        if p_str ==\"device_ip\" and id_day['day_'+pdip] == 1:\n",
    "            df[p_str]+=\"#ips\"\n",
    "    df['uid_day'] = \"id_day_\"+str(id_day[\"uday_\"+uuid])\n",
    "    return df\n",
    "            "
   ],
   "metadata": {
    "collapsed": false,
    "pycharm": {
     "name": "#%%\n",
     "is_executing": false
    }
   }
  },
  {
   "cell_type": "code",
   "execution_count": 17,
   "outputs": [],
   "source": [
    "def prep(df):\n",
    "    global count,uuid,pdip\n",
    "    count+=1\n",
    "    if count%500000 ==0:\n",
    "        print(count)\n",
    "    for p_str in list(columns[2:]):\n",
    "        if p_str == 'device_id':\n",
    "            did = \"did_\"+df['device_id']\n",
    "            rare = rare_d.get(did)\n",
    "            if rare !=None:\n",
    "                df['device_id'] = \"did_rare_\"+ str(rare)\n",
    "                continue\n",
    "        if p_str == 'device_ip':\n",
    "            dip = \"dip_\"+df['device_ip']\n",
    "            pdip = df['device_ip']\n",
    "            rare = rare_d.get(dip)\n",
    "            if rare !=None:\n",
    "                df['device_ip'] = \"dip_rare_\"+ str(rare)\n",
    "                continue\n",
    "        if p_str == 'user_id':\n",
    "            uid = \"uid_\"+df['user_id']\n",
    "            uuid = df['user_id']\n",
    "            rare = rare_d.get(uid)\n",
    "            if rare !=None:\n",
    "                df['user_id'] = \"uid_rare_\"+ str(rare)\n",
    "                continue\n",
    "            elif id_day.get(uid) == 1:\n",
    "                df['user_id'] = \"v_id_s\"\n",
    "                continue\n",
    "        if p_str+\"_\"+str(df[p_str]) not in fset and p_str not in list(columns[-7:]):\n",
    "            df[p_str] = p_str+\"_rare\"\n",
    "        else:\n",
    "            df[p_str] = p_str +\"_\" + str(df[p_str])\n",
    "        if p_str ==\"device_ip\" and id_day['day_'+pdip] == 1:\n",
    "            df[p_str]+=\"#ips\"\n",
    "    df['uid_day'] = \"id_day_\"+str(id_day[\"uday_\"+uuid])\n",
    "    return df"
   ],
   "metadata": {
    "collapsed": false,
    "pycharm": {
     "name": "#%%\n",
     "is_executing": false
    }
   }
  },
  {
   "cell_type": "code",
   "execution_count": 100,
   "outputs": [],
   "source": [
    "#dfinput = pd.read_csv('train_sub_count.csv',nrows=50,chunksize=5)\n"
   ],
   "metadata": {
    "collapsed": false,
    "pycharm": {
     "name": "#%%\n",
     "is_executing": false
    }
   }
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "outputs": [],
   "source": [],
   "metadata": {
    "collapsed": false,
    "pycharm": {
     "name": "#%%\n"
    }
   }
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "outputs": [],
   "source": [
    "for i in dfinput:\n",
    "    i = i.apply(prep,axis=1)\n",
    "    i.to_csv(\"C:\\\\PY-Project\\\\train_pre.csv\",mode=\"a\",header=False,index=False)"
   ],
   "metadata": {
    "collapsed": false,
    "pycharm": {
     "name": "#%%\n"
    }
   }
  },
  {
   "cell_type": "code",
   "execution_count": 18,
   "outputs": [
    {
     "name": "stdout",
     "text": [
      "500000\n",
      "1000000\n",
      "1500000\n",
      "2000000\n",
      "2500000\n",
      "3000000\n",
      "3500000\n",
      "4000000\n",
      "4500000\n"
     ],
     "output_type": "stream"
    }
   ],
   "source": [
    "for i in dtinput:\n",
    "    i = i.apply(prep,axis=1)\n",
    "    i.to_csv(\"C:\\\\PY-Project\\\\test_pre_over.csv\",mode=\"a\",header=False,index=False)"
   ],
   "metadata": {
    "collapsed": false,
    "pycharm": {
     "name": "#%%\n",
     "is_executing": false
    }
   }
  },
  {
   "cell_type": "code",
   "execution_count": 22,
   "outputs": [],
   "source": [
    "testaaa = pd.read_csv('test_pre_over.csv',nrows=50)"
   ],
   "metadata": {
    "collapsed": false,
    "pycharm": {
     "name": "#%%\n",
     "is_executing": false
    }
   }
  },
  {
   "cell_type": "code",
   "execution_count": 23,
   "outputs": [
    {
     "data": {
      "text/plain": "             id      hour       C1    banner_pos           site_id  \\\n0  1.000017e+19  14103100  C1_1005  banner_pos_0  site_id_235ba823   \n1  1.000018e+19  14103100  C1_1005  banner_pos_0  site_id_1fbe01fe   \n2  1.000055e+19  14103100  C1_1005  banner_pos_0  site_id_1fbe01fe   \n3  1.000109e+19  14103100  C1_1005  banner_pos_0  site_id_85f751fd   \n4  1.000138e+19  14103100  C1_1005  banner_pos_0  site_id_85f751fd   \n\n            site_domain           site_category           app_id  \\\n0  site_domain_f6ebf28e  site_category_f028772b  app_id_ecad2386   \n1  site_domain_f3845767  site_category_28905ebd  app_id_ecad2386   \n2  site_domain_f3845767  site_category_28905ebd  app_id_ecad2386   \n3  site_domain_c4e18dd6  site_category_50e219e0  app_id_51cedd4e   \n4  site_domain_c4e18dd6  site_category_50e219e0  app_id_9c13b419   \n\n            app_domain           app_category  ...         C20      C21  \\\n0  app_domain_7801e8d9  app_category_07d7df22  ...  C20_100075   C21_23   \n1  app_domain_7801e8d9  app_category_07d7df22  ...  C20_100083   C21_51   \n2  app_domain_7801e8d9  app_category_07d7df22  ...  C20_100083   C21_51   \n3  app_domain_aefc06bd  app_category_0f2161f8  ...  C20_100156   C21_61   \n4  app_domain_2347f47a  app_category_f95efa07  ...      C20_-1  C21_221   \n\n      user_id    user_id&media_id    user_id&C14_d    user_id&C17_d  \\\n0  uid_rare_4  user_id&media_id_1  user_id&C14_d_1  user_id&C17_d_1   \n1  uid_rare_5  user_id&media_id_1  user_id&C14_d_1  user_id&C17_d_1   \n2  uid_rare_7  user_id&media_id_1  user_id&C14_d_1  user_id&C17_d_1   \n3  uid_rare_7  user_id&media_id_1  user_id&C14_d_1  user_id&C17_d_1   \n4  uid_rare_1  user_id&media_id_1  user_id&C14_d_1  user_id&C17_d_1   \n\n     user_id&C14_h    user_id&C17_h     time   uid_day  \n0  user_id&C14_h_1  user_id&C17_h_1  time_-1  id_day_1  \n1  user_id&C14_h_1  user_id&C17_h_1  time_-1  id_day_3  \n2  user_id&C14_h_1  user_id&C17_h_1  time_-1  id_day_3  \n3  user_id&C14_h_1  user_id&C17_h_1  time_-1  id_day_1  \n4  user_id&C14_h_1  user_id&C17_h_1  time_-1  id_day_1  \n\n[5 rows x 31 columns]",
      "text/html": "<div>\n<style scoped>\n    .dataframe tbody tr th:only-of-type {\n        vertical-align: middle;\n    }\n\n    .dataframe tbody tr th {\n        vertical-align: top;\n    }\n\n    .dataframe thead th {\n        text-align: right;\n    }\n</style>\n<table border=\"1\" class=\"dataframe\">\n  <thead>\n    <tr style=\"text-align: right;\">\n      <th></th>\n      <th>id</th>\n      <th>hour</th>\n      <th>C1</th>\n      <th>banner_pos</th>\n      <th>site_id</th>\n      <th>site_domain</th>\n      <th>site_category</th>\n      <th>app_id</th>\n      <th>app_domain</th>\n      <th>app_category</th>\n      <th>...</th>\n      <th>C20</th>\n      <th>C21</th>\n      <th>user_id</th>\n      <th>user_id&amp;media_id</th>\n      <th>user_id&amp;C14_d</th>\n      <th>user_id&amp;C17_d</th>\n      <th>user_id&amp;C14_h</th>\n      <th>user_id&amp;C17_h</th>\n      <th>time</th>\n      <th>uid_day</th>\n    </tr>\n  </thead>\n  <tbody>\n    <tr>\n      <th>0</th>\n      <td>1.000017e+19</td>\n      <td>14103100</td>\n      <td>C1_1005</td>\n      <td>banner_pos_0</td>\n      <td>site_id_235ba823</td>\n      <td>site_domain_f6ebf28e</td>\n      <td>site_category_f028772b</td>\n      <td>app_id_ecad2386</td>\n      <td>app_domain_7801e8d9</td>\n      <td>app_category_07d7df22</td>\n      <td>...</td>\n      <td>C20_100075</td>\n      <td>C21_23</td>\n      <td>uid_rare_4</td>\n      <td>user_id&amp;media_id_1</td>\n      <td>user_id&amp;C14_d_1</td>\n      <td>user_id&amp;C17_d_1</td>\n      <td>user_id&amp;C14_h_1</td>\n      <td>user_id&amp;C17_h_1</td>\n      <td>time_-1</td>\n      <td>id_day_1</td>\n    </tr>\n    <tr>\n      <th>1</th>\n      <td>1.000018e+19</td>\n      <td>14103100</td>\n      <td>C1_1005</td>\n      <td>banner_pos_0</td>\n      <td>site_id_1fbe01fe</td>\n      <td>site_domain_f3845767</td>\n      <td>site_category_28905ebd</td>\n      <td>app_id_ecad2386</td>\n      <td>app_domain_7801e8d9</td>\n      <td>app_category_07d7df22</td>\n      <td>...</td>\n      <td>C20_100083</td>\n      <td>C21_51</td>\n      <td>uid_rare_5</td>\n      <td>user_id&amp;media_id_1</td>\n      <td>user_id&amp;C14_d_1</td>\n      <td>user_id&amp;C17_d_1</td>\n      <td>user_id&amp;C14_h_1</td>\n      <td>user_id&amp;C17_h_1</td>\n      <td>time_-1</td>\n      <td>id_day_3</td>\n    </tr>\n    <tr>\n      <th>2</th>\n      <td>1.000055e+19</td>\n      <td>14103100</td>\n      <td>C1_1005</td>\n      <td>banner_pos_0</td>\n      <td>site_id_1fbe01fe</td>\n      <td>site_domain_f3845767</td>\n      <td>site_category_28905ebd</td>\n      <td>app_id_ecad2386</td>\n      <td>app_domain_7801e8d9</td>\n      <td>app_category_07d7df22</td>\n      <td>...</td>\n      <td>C20_100083</td>\n      <td>C21_51</td>\n      <td>uid_rare_7</td>\n      <td>user_id&amp;media_id_1</td>\n      <td>user_id&amp;C14_d_1</td>\n      <td>user_id&amp;C17_d_1</td>\n      <td>user_id&amp;C14_h_1</td>\n      <td>user_id&amp;C17_h_1</td>\n      <td>time_-1</td>\n      <td>id_day_3</td>\n    </tr>\n    <tr>\n      <th>3</th>\n      <td>1.000109e+19</td>\n      <td>14103100</td>\n      <td>C1_1005</td>\n      <td>banner_pos_0</td>\n      <td>site_id_85f751fd</td>\n      <td>site_domain_c4e18dd6</td>\n      <td>site_category_50e219e0</td>\n      <td>app_id_51cedd4e</td>\n      <td>app_domain_aefc06bd</td>\n      <td>app_category_0f2161f8</td>\n      <td>...</td>\n      <td>C20_100156</td>\n      <td>C21_61</td>\n      <td>uid_rare_7</td>\n      <td>user_id&amp;media_id_1</td>\n      <td>user_id&amp;C14_d_1</td>\n      <td>user_id&amp;C17_d_1</td>\n      <td>user_id&amp;C14_h_1</td>\n      <td>user_id&amp;C17_h_1</td>\n      <td>time_-1</td>\n      <td>id_day_1</td>\n    </tr>\n    <tr>\n      <th>4</th>\n      <td>1.000138e+19</td>\n      <td>14103100</td>\n      <td>C1_1005</td>\n      <td>banner_pos_0</td>\n      <td>site_id_85f751fd</td>\n      <td>site_domain_c4e18dd6</td>\n      <td>site_category_50e219e0</td>\n      <td>app_id_9c13b419</td>\n      <td>app_domain_2347f47a</td>\n      <td>app_category_f95efa07</td>\n      <td>...</td>\n      <td>C20_-1</td>\n      <td>C21_221</td>\n      <td>uid_rare_1</td>\n      <td>user_id&amp;media_id_1</td>\n      <td>user_id&amp;C14_d_1</td>\n      <td>user_id&amp;C17_d_1</td>\n      <td>user_id&amp;C14_h_1</td>\n      <td>user_id&amp;C17_h_1</td>\n      <td>time_-1</td>\n      <td>id_day_1</td>\n    </tr>\n  </tbody>\n</table>\n<p>5 rows × 31 columns</p>\n</div>"
     },
     "metadata": {},
     "output_type": "execute_result",
     "execution_count": 23
    }
   ],
   "source": [
    "testaaa.head()\n",
    "# train_df2.to_csv(\"C:\\\\PY-Project\\\\aaa.csv\")"
   ],
   "metadata": {
    "collapsed": false,
    "pycharm": {
     "name": "#%%\n",
     "is_executing": false
    }
   }
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "outputs": [],
   "source": [
    "# dtrain = dtrain.apply(prep,axis=1)"
   ],
   "metadata": {
    "collapsed": false,
    "pycharm": {
     "name": "#%%\n"
    }
   }
  },
  {
   "cell_type": "code",
   "execution_count": 41,
   "outputs": [],
   "source": [
    "# train_df2 = train_df2.apply(prep,axis=1)\n",
    "# "
   ],
   "metadata": {
    "collapsed": false,
    "pycharm": {
     "name": "#%%\n",
     "is_executing": false
    }
   }
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "outputs": [],
   "source": [
    "# train_df.to_csv(\"train_pre.csv\")\n",
    "#             \n",
    "        "
   ],
   "metadata": {
    "collapsed": false,
    "pycharm": {
     "name": "#%%\n",
     "is_executing": true
    }
   }
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 2
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython2",
   "version": "2.7.6"
  },
  "pycharm": {
   "stem_cell": {
    "cell_type": "raw",
    "source": [],
    "metadata": {
     "collapsed": false
    }
   }
  }
 },
 "nbformat": 4,
 "nbformat_minor": 0
}